<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<meta name="keywords" content="">
<meta name="description" content="">
<title>参赛报名信息</title>
<link href=" {{asset('css/style.css')}}" rel="stylesheet" type="text/css">

</head>
<body class="body_gray">
<div class="wrap">

  <div class="top">
    <a class="btn_back" href="javascript:history.back(-1);"></a>
    <div class="tit">参赛报名信息</div>
    
  </div>

<div class="main">
  <div class="bm_form">
  

    <dl>
      <dt><span class="red">*</span>作者姓名：</dt>
      <dd><input class="input" id="author" type="text" value="" /></dd>
    </dl>
    <dl>
      <dt><span class="red">*</span>作者昵称：</dt>
      <dd><input class="input" id="nickname"  type="text" value="" /></dd>
    </dl>
    <dl>
      <dt><span class="red">*</span>手机号码：</dt>
      <dd><input class="input" id="phone" type="text" value="" /></dd>
    </dl>
    <dl>
      <dt><span class="red">*</span>推广语：</dt>
      <dd><input class="input" id="advertisement"  type="text" value="" /></dd>
    </dl>
    <dl>
      <dt><span class="red">*</span>创意说明：</dt>
      <dd>
        <textarea id="explain" class="textarea"></textarea>
      </dd>
    </dl>
     
     {{--<div class="btn_w"><input class="btn" id="applyRequest" type="button" value="提交" /></div>--}}
    <dl>
    <div id="applyRequest" class="applybutton">
      提交
    </div>
    </dl>

  </div>
</div>

</div>
<script type="text/javascript" src="{{asset('js/validate.js')}}"></script>
<script type="text/javascript" src="{{asset('js/jquery-1.9.1.js')}}"></script>
<script type="text/javascript">
  $(function(){
    $("#applyRequest").on("click", function(){
        if('' == $("#author").val()){
                  alert("请输入用户名");
                  return;
        }
        if(!isChineseName($("#author").val())){
          alert("用户名必须是2-5个中文字符");
          return;
        }

        if('' == $("#nickname").val()){
          alert("请输入昵称");
          return;
        }

        if(!isNickname($("#nickname").val())){
          alert("昵称必须是3-7个字符");
          return;
        }

        if('' == $("#phone").val()){
          alert("请输入手机号");
          return;
        }

        if(!isTelephone($("#phone").val())){
          alert("请输入正确的手机号码");
          return;
        }

        if('' == $("#advertisement").val()){
          alert("请输入推广语");
          return;
        }
          if(!isChineseCharacter($("#advertisement").val(),5,20)){
            alert("推广语必须是5-20个字符");
            return;
         }
        if('' == $("#explain").val()){
          alert("请输入创意说明");
          return;
        }
        if($("#explain").val().length < 5 || $("#explain").val().length > 300){
        alert("创意说明必须是5-300个字符");
        return;
        }

        var postdata = {
          'author' : $("#author").val(),
          'nickname' : $("#nickname").val(),
          'phone' : $("#phone").val(),
          'advertisement' : $("#advertisement").val(),
          'explain' : $("#explain").val(),
          '_token' : '{{csrf_token()}}'
        };
        $.ajax({
          type: "POST",
          url: "{{url('contest/apply')}}",
          data: postdata,
          async: false
        }).success(function(data){
          if(data.state == 'success'){
            alert("提交成功");
            window.location.href = '{{url('contest/list')}}';
          }else{
            alert("提交失败");
          }
        })

      });
  })
</script>
</body>
</html>